﻿namespace System.ServiceModel.DomainServices.Client
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.ComponentModel.DataAnnotations;

    public class InvokeCompletedResult
    {
        private object _returnValue;
        private ReadOnlyCollection<ValidationResult> _validationErrors;

        public InvokeCompletedResult(object returnValue) : this(returnValue, new ValidationResult[0])
        {
        }

        public InvokeCompletedResult(object returnValue, IEnumerable<ValidationResult> validationErrors)
        {
            if (validationErrors == null)
            {
                throw new ArgumentNullException("validationErrors");
            }
            this._returnValue = returnValue;
            this._validationErrors = validationErrors.ToList<ValidationResult>().AsReadOnly();
        }

        public object ReturnValue
        {
            get
            {
                return this._returnValue;
            }
        }

        public IEnumerable<ValidationResult> ValidationErrors
        {
            get
            {
                return this._validationErrors;
            }
        }
    }
}

